package com.study.chunguard.common.exception.code;

/**
 * 通用错误码
 *
 * @author Lei
 * @since 2022/10/26 20:12
 */
@SuppressWarnings("AlibabaEnumConstantsMustHaveComment")
public enum ResponseCode implements CodeMsg {

    SUCCESS(0, "操作成功"),
    FAIL(1, "操作失败"),

    SYSTEM_BUSY(500001, "系统繁忙，请稍候再试"),
    OPERATION_ERROR(500002, "操作失败"),
    FIELD_BINDING_ERROR(400001, "请求字段参数校验失败"),
    FIELD_FORMAT_ERROR(400002, "请求参数格式错误"),
    FIELD_MISSING_ERROR(400003, "请求参数不完整或不对"),
    REQUEST_BODY_MISSING(400004, "需要请求体"),

    ACCOUNT_CLIENT_ERROR(400000, "用户端错误"),

    ACCOUNT_REGISTER_ERROR(400100, "用户注册异常"),
    ACCOUNT_EXISTS(400101, "用户名已存在"),
    ACCOUNT_ERROR(400102, "用户名校验错误"),
    ACCOUNT_CONTAINS_SENSITIVE(400103, "用户名包含敏感词 "),
    ACCOUNT_CONTAINS_SPECIAL(400104, "用户名包含特殊字符"),
    PASSWORD_ERROR(400105, "密码校验错误"),
    PASSWORD_TOO_SHORT(400106, "密码长度不够"),
    PASSWORD_TOO_WEAK(400107, "密码强度不够"),
    VCODE_ERROR(400108, "校验码错误"),
    SMS_VCODE_ERROR(400109, "短信校验码错误"),
    EMAIL_VCODE_ERROR(400110, "邮件校验码错误"),
    ID_NUMBER_FORMAT_ERROR(400111, "身份证号格式错误"),
    PHONE_NUMBER_FORMAT_ERROR(400112, "手机号格式错误"),
    ADDRESS_ERROR(400113, "地址错误"),
    EMAIL_FORMAT_ERROR(400114, "邮箱格式错误"),

    ACCOUNT_LOGIN_EXCEPTION(400200, "用户登录异常"),
    NOT_ACCOUNT(400201, "用户名不存在"),
    ACCOUNT_IS_LOCKED(400202, "用户被锁定，请联系管理人员"),
    ACCOUNT_HAS_EXPIRED(400203, "用户已作废"),
    USERNAME_OR_PASSWORD_WRONG(400204, "用户名或密码错误"),
    WRONG_PASSWORD(400205, "密码错误"),
    WRONG_PASSWORDS_OVER_LIMIT(400206, "用户输入密码错误次数超限"),
    ACCOUNT_LOGIN_EXPIRED(400207, "用户登录已过期"),
    ACCOUNT_VCODE_ERROR(400208, "用户验证码错误"),
    WRONG_VCODE_OVER_LIMIT(400209, "用户验证码错误次数超限"),
    NO_AUTHORIZED(400210, "用户未获得第三方登录授权 "),
    NO_SESSION(400211, "登录信息失效"),
    CREDENTIALS_EXPIRED(400212, "登录凭证已过期，请重新登录"),
    CREDENTIALS_EXCEPTION(400213, "登录凭证异常，请重新登录"),
    ID_NUMBER_ERROR(400214, "身份证号错误"),
    PHONE_NUMBER_ERROR(400215, "手机号错误"),
    EMAIL_ERROR(400216, "邮箱错误"),
    PASSWORD_EXPIRED(400217, "密码过期，请修改密码"),

    ACCOUNT_ACCESS_EXCEPTION(400300, "用户访问权限异常"),
    ACCESS_UNAUTHORIZED(400301, "访问未授权"),
    NOT_TOKEN(400302, "未提供token"),
    TOKEN_INVALID(400303, "token无效"),
    TOKEN_TIMEOUT(400304, "token已过期"),
    TOKEN_BE_REPLACED(400305, "token已被顶下线"),
    TOKEN_KICK_OUT(400306, "token已被踢下线"),
    TOKEN_OTHER(400307, "token异常"),

    PARAMETER_ERROR(400400, "用户请求参数错误"),
    NOT_PARAMETER(400401, "请求必填参数为空"),
    PARAMETER_VERIFICATION_ERROR(400402, "请求参数指定校验失败"),
    PARAMETER_FORMAT_ERROR(400403, "请求参数格式错误"),
    INCOMPLETE_PARAMETERS(400404, "请求参数不完整"),
    NOT_REQUEST_BODY(400405, "无请求体"),
    NOT_ID(400406, "id为空"),
    NOT_ORGCODE(400407, "机构编码为空"),
    NOT_SITECODE(400408, "站点编码为空"),

    PERMISSION_MANAGEMENT_EXCEPTION(400500, "权限管理异常"),
    NOT_ORG(400501, "机构不存在"),
    ORG_HAS_SUBORG(400502, "该机构存在下级机构，无法删除"),
    ORGNAME_EXISTS(400503, "机构名已存在"),
    ORG_LINKED_USER(400504, "机构关联用户，无法删除"),
    ROLENAME_EXISTS(400505, "角色名已存在"),
    ROLE_LINKED_USER(400506, "角色关联用户，无法删除"),
    NOT_ROLE(400507, "角色为空"),
    NOT_PERMISSION(400508, "权限为空"),

    REQUEST_SERVICE_EXCEPTION(400600, "用户请求服务异常"),
    REQUEST_COUNT_OVER_LIMIT(400601, "请求次数超出限制 "),
    REQUEST_CONCURRENCY_COUNT_OVER_LIMIT(400602, "请求并发数超出限制 "),
    WEBSOCKET_CONNECTION_EXCEPTION(400603, "WebSocket 连接异常"),
    WEBSOCKET_CONNECTION_DISCONNECTED(400604, "WebSocket 连接断开"),
    USER_REPEATED_REQUEST(400605, "用户重复请求"),

    GATEWAY_ERROR(400700, "网关异常"),
    GATEWAY_NOT_FOUND_SERVICE(400701, "服务未找到"),
    GATEWAY_CONNECT_TIME_OUT(400702, "网关超时"),
    UPLOAD_FILE_SIZE_LIMIT(400703, "上传文件大小超过限制"),
    DUPLICATE_PRIMARY_KEY(400704, "唯一键冲突"),

    SYSTEM_ERROR(500000, "系统端错误"),
    SYSTEM_LICENSE_ERROR(500100, "系统许可证错误");


    /**
     * 错误码
     */
    private final Integer code;

    /**
     * 错误消息
     */
    private final String msg;

    ResponseCode(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getMsg() {
        return msg;
    }
}
